// ///////// 统一填报-表单设计
import { default as request, cloud } from '@/framework/utils/request'

// 分页查询定制化表单所有数据
export function customFormInfoPage(query) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/page',
    method: 'get',
    params: query
  })
}
// 表单详情
export function customFormInfoDetail(formId) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/detail?formId=' + formId,
    method: 'get'
  })
}
// 新增定制化表单数据
export function formDesignAdd(data) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/add',
    method: 'post',
    data: data
  })
}
// 修改定制化表单数据
export function formDesignEdit(data) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/edit',
    method: 'post',
    data: data
  })
}
// 删除定制化表单数据
export function formDesignDelete(formId) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/delete',
    method: 'post',
    data: { formId: formId }
  })
}
// 保存表单页面设计
export function savePageDesign(data) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/savePageDesign',
    method: 'post',
    data: data
  })
}

// ///统一填报-表单数据
// 获取表单结构
export function getFormJson(query) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/queryPageDesign',
    method: 'get',
    params: query
  })
}
// 表单数据-列表
export function getList(query) {
  return request({
    url: cloud.unifiedreport + '/customFormData/getList',
    method: 'get',
    params: query
  })
}
// 表单数据 -新增
export function formDataAdd(query, url, method) {
  console.log(query, url, method)
  return request({
    url: cloud.unifiedreport + url,
    method: method,
    data: query
  })
}
// 表单数据 -编辑
export function formDataEdit(query, url, method) {
  return request({
    url: cloud.unifiedreport + url || cloud.unifiedreport + '/customFormData/edit',
    method: method,
    data: query
  })
}
// 表单数据 -删除
export function formDataDeletes(query, url, method) {
  return request({
    url: cloud.unifiedreport + '/customFormData/delete',
    method: 'post',
    data: query
  })
}

// 表单数据详情 主表
export function customFormDataDetail(query) {
  return request({
    url: cloud.unifiedreport + '/customFormData/detail',
    method: 'get',
    params: query
  })
}
// 表单数据详情 从表列表
export function getDetailTableList(query) {
  return request({
    url: cloud.unifiedreport + '/customFormData/getDetailTableList',
    method: 'get',
    params: query
  })
}
// 获取字典表
export function getDictList(params) {
  return request({
    url: cloud.dqbasic + '/dict/list',
    method: 'get',
    params
  })
}

// 判断从表名重复
export function existTableCode(query) {
  return request({
    url: cloud.unifiedreport + '/customFormInfo/existTableCode',
    method: 'get',
    params: query
  })
}
